package com.chushouya.product.service.common.impl;

import com.chushouya.product.dao.entity.ProductEntity;
import com.chushouya.product.dao.repository.ProductRepository;
import com.chushouya.product.service.common.CommonProductService;
import com.general.framework.core.exception.Ex;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Objects;

@Service
public class CommonProductServiceImpl implements CommonProductService {

    @Resource
    private ProductRepository productRepository;

    @Override
    public ProductEntity getProductInfo(Long productId) {
        ProductEntity product = productRepository.selectByPrimaryKey(productId);
        if (Objects.isNull(product)) {
            throw Ex.business("商品不存在");
        }
        return product;
    }
}
